//
//  TrainDetailViewController.m
//  dogGroup
//
//  Created by iOS Two on 14-8-13.
//  Copyright (c) 2014年 iOS Two. All rights reserved.
//

#import "TrainDetailViewController.h"

@interface TrainDetailViewController ()

@end

@implementation TrainDetailViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}
-(void)viewWillAppear:(BOOL)animated {
    [MobClick beginLogPageView:@"TrainDetailViewController"];
}
-(void)viewDidDisappear:(BOOL)animated {
    [self clearAllUIWebViewData];
    [MobClick endLogPageView:@"TrainDetailViewController"];
}
- (void)viewDidLoad
{
    [super viewDidLoad];
    
    UILabel *titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 100, 30)];
    titleLabel.text = _trainTitle;
    titleLabel.backgroundColor = [UIColor clearColor];
    titleLabel.textAlignment = NSTextAlignmentCenter;
    titleLabel.textColor = [UIColor whiteColor];
    self.navigationItem.titleView = titleLabel;
    UIImageView *image = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, kwidth, 568)];
    image.image = [UIImage imageNamed:@"dididid_01"];
    [self.view addSubview:image];
    _web = [[UIWebView alloc]init];
    if (version >= 7) {
        _web.frame = CGRectMake(0, 0, 320, kHeight - 64);
    } else {
        _web.frame = CGRectMake(0, 0, 320, kHeight - 44);
    }
    _web.delegate = self;
    _web.opaque = NO;
    _web.backgroundColor = [UIColor clearColor];
    [_web loadHTMLString:[_trainInfo stringByReplacingOccurrencesOfString:@"\\" withString:@""] baseURL:nil];
    [self.view addSubview:_web];
}
- (void)webViewDidStartLoad:(UIWebView *)webView {
    [self showIndeterminateProgress];
}

- (void)webViewDidFinishLoad:(UIWebView *)webView {
    [HUD hide:YES];
    [_web stringByEvaluatingJavaScriptFromString:@"document.getElementsByTagName('body')[0].style.webkitTextFillColor= 'darkpurple'"];
    [_web stringByEvaluatingJavaScriptFromString:@"document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust= '110%'"];
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
